<?php
namespace module\app\middleware;

use app\Request;
use app\helper\Ident;

class Auth
{
    public function handle(Request $request, \Closure $next)
    {
        try {
            $payload = Ident::auth();
            $request->uid = $payload->uid;
            $request->account = $payload->mobile;
        } catch (\Exception $e) {
            return json(['code' => 401, 'msg' => $e->getMessage()]);
        }

        return $next($request);
    }
}